<%-- 
    Document   : makeJoinTeam
    Created on : Jul 2, 2011, 11:20:56 PM
    Author     : Hung
--%>
<%-- 
    Document   : getLab4Team
    Created on : Jul 2, 2011, 10:15:38 PM
    Author     : Hung
--%>
<%@page import="java.util.ArrayList"%>
<jsp:useBean id="labData" scope="application" class="edu.gatech.gellinservlet.model.LabManager" />
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="style.css"/>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Sign-up for Courses - Lab Assistant Pro</title>
    </head>
    <body>
        <%@include file="pro_header.jsp" %>
        <%@include file="stude_list.jsp" %>
    <center>
        <h1>Select a team to join!</h1>
    </center>
    <table ALIGN="center" border="1" cellspacing="0" cellpadding="0">
        <form action="joinTeam.jsp" method="post"/>
            <tbody>
                <tr>
                    <td>Teams:</td>
                    <td>
                        <% 
                            int count = 0;
                            String labName = request.getParameter("lab");
                            //System.out.println(labName);
                            //String url = "makeTeam.jsp?" + labName;
                            Lab aLab = labData.search(labName);
                            session.setAttribute("persistLab", aLab);
    
                            String output = "<select name=\"team\">";
                            for (Team aTeam : aLab.getTeamList())
                            {
                                
                                    count++;
                                    String name = aTeam.getName();
                                    output += ("<option value=\"" + name + "\">");
                                    output += (name);
                                    output += ("</option>");
                                
                            }
                            if (count == 0)
                            {
                                output = "There is no team to join but you might be able to create a team.";
                            } else
                            {
                                output += "</select>";
                            }
                            out.println(output);
                        %>

                    </td>
                </tr>
                <tr>
                    <td><input type="submit" value="Join Team" name="signup" 
                               <% if (count == 0)
                                   {
                                       out.println("disabled=\"\"");
                                   }
                               %>/>
                        </input></td>
                </tr>
            </tbody>
            <!-- 
            This does not show up on the actual page, but is necessary for storing
            the name of the lab the student is wanting to join the team in.
            -->
            <input hidden="" type="text" name="labName" readonly="readonly" 
                                <%
                                
                                out.println("value=\"" + labName + "\"");
                                %>
            />
        </form>
    </table>
    
    <center>
        <h1>Create a team!</h1>
    </center>
    <table ALIGN="center" border="1" cellspacing="0" cellpadding="0">
        
        <form action="makeTeam.jsp" method="post"/>
        <input hidden="" type="text" name="labName" readonly="readonly" 
                                <%
                                
                                out.println("value=\"" + labName + "\"");
                                %>
            />
            <tbody>
                <tr>
                  <!--  <td> We already selected a lab to join on the previous page; don't want to annoy user
                        Lab Joining:
                    </td> -->
                </tr>
                <tr>
                    <td>Team Name:</td>
                    <td>
                      
                        
                        <input type="text" name="teamName"/>
                       
                        
                    </td>
                </tr>
                <tr>
                    <td><input type="submit" value="Create Team" name="signup"/>     
                        </input></td>
                </tr>
            </tbody>
        </form>
    </table>
    
    <% } //ends user_redirect else statement, html is included here %>
    <% } //ends verifySession.jsp, all html is included in else statment %>
</body>
</html>

